package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.WorkExperience;
import com.ruoyi.system.service.IWorkExperienceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 工作经历Controller
 * 
 * @author ruoyi
 * @date 2025-05-22
 */
@Api(tags = "工作经历管理")
@RestController
@RequestMapping("/system/experience")
public class WorkExperienceController extends BaseController
{
    @Autowired
    private IWorkExperienceService workExperienceService;

    /**
     * 查询工作经历列表
     */
    @ApiOperation(value = "查询工作经历列表", notes = "查询工作经历列表")
    @PreAuthorize("@ss.hasPermi('system:experience:list')")
    @GetMapping("/list")
    public TableDataInfo list(WorkExperience workExperience)
    {
        startPage();
        List<WorkExperience> list = workExperienceService.selectWorkExperienceList(workExperience);
        return getDataTable(list);
    }

    /**
     * 导出工作经历列表
     */
    @ApiOperation(value = "导出工作经历列表", notes = "导出工作经历列表")
    @PreAuthorize("@ss.hasPermi('system:experience:export')")
    @Log(title = "工作经历", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WorkExperience workExperience)
    {
        List<WorkExperience> list = workExperienceService.selectWorkExperienceList(workExperience);
        ExcelUtil<WorkExperience> util = new ExcelUtil<WorkExperience>(WorkExperience.class);
        util.exportExcel(response, list, "工作经历数据");
    }

    /**
     * 获取工作经历详细信息
     */
    @ApiOperation(value = "获取工作经历详细信息", notes = "获取工作经历详细信息")
    @PreAuthorize("@ss.hasPermi('system:experience:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(workExperienceService.selectWorkExperienceById(id));
    }

    /**
     * 新增工作经历
     */
    @ApiOperation(value = "新增工作经历", notes = "新增工作经历")
    @PreAuthorize("@ss.hasPermi('system:experience:add')")
    @Log(title = "工作经历", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WorkExperience workExperience)
    {
        return toAjax(workExperienceService.insertWorkExperience(workExperience));
    }

    /**
     * 修改工作经历
     */
    @ApiOperation(value = "修改工作经历", notes = "修改工作经历")
    @PreAuthorize("@ss.hasPermi('system:experience:edit')")
    @Log(title = "工作经历", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WorkExperience workExperience)
    {
        return toAjax(workExperienceService.updateWorkExperience(workExperience));
    }

    /**
     * 删除工作经历
     */
    @ApiOperation(value = "删除工作经历", notes = "删除工作经历")
    @PreAuthorize("@ss.hasPermi('system:experience:remove')")
    @Log(title = "工作经历", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(workExperienceService.deleteWorkExperienceByIds(ids));
    }
}
